import {Component, Input, OnInit } from '@angular/core';
import { Response } from '@angular/http';
import {GoodsDetailService} from "../../service/goods-detail.service";

@Component({
  selector: 'app-goods-slidershow',
  templateUrl: './goods-slidershow.component.html',
  styleUrls: ['./goods-slidershow.component.less']
})
export class GoodsSlidershowComponent implements OnInit {
  @Input('images') images;
  isFirst = false;
  isLast = false;
  currentIndex = 4;
  currentImgIndex = 0;
  constructor(private goodsDetailService: GoodsDetailService) { }

  ngOnInit() {

  }
  prevPage() {
    console.log(this.currentIndex);
    if (this.currentIndex === 4) {
      this.currentIndex = 4;
      this.isFirst = true;
    } else {
      this.currentIndex -= 1;
    }
  }
  nextPage() {
    console.log(this.currentIndex);
    if (this.currentIndex === this.images.length - 1) {
      this.currentIndex = this.images.length - 1;
      this.isLast = true;
    } else {
      this.currentIndex += 1;
    }

  }
  go(index: number) {
    this.currentImgIndex = index;
  }
}
